package com.service.impl;

import com.dao.FriendMessageDao;
import com.entity.FriendMessage;
import com.service.FriendMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class FriendMessageServiceImpl implements FriendMessageService {
    @Autowired
    private FriendMessageDao friendMessageDao;


    @Override
    public List<FriendMessage> getByFriendId(Integer userId, Integer friendId) {
        return friendMessageDao.getByFriendId(userId,friendId);
    }

    @Override
    public List<FriendMessage> getAll(Integer pageNum, Integer pageSize, Integer userId, Integer friendId) {
        return friendMessageDao.getAll(pageNum, pageSize, userId, friendId);
    }

    @Override
    @Transactional
    public FriendMessage addFiendMessage(FriendMessage friendMessage) {
        friendMessageDao.addFiendMessage(friendMessage);
        return friendMessageDao.getById(friendMessage.getId());
    }

    @Override
    public Integer getNotReadCount(Integer userId, Integer friendId) {
        return friendMessageDao.getNotReadCount(userId, friendId);
    }

    @Override
    public void editToRead(Integer userId, Integer friendId) {
        friendMessageDao.editToRead(userId, friendId);
    }

    @Override
    public void editBackById(Integer id) {
        friendMessageDao.editBackById(id);
    }
}
